$.ajax({
		type:"post",
		url:"",
		async:true,
		data:'releaseAnnounce',
		success:function(){
			
		},
		error:function(){
			$('#cue').html('跳转出现错误' + jqXHR.status);
		}
	});

var oUpload = document.getElementById('upload');
var oAgomess = document.getElementById('agomess');
var oKeep = document.getElementById('keep');
var oDelete = document.getElementById('delete');
oKeep.onclick = function(){

	var aAnn = document.createElement("li");
	var oContent = document.createElement('span');
	var oTitle = document.createElement("span");
	var odel = document.createElement('input');
	
	var oTit = document.getElementById('title');
	var oArea = document.getElementById('announce-content');
	
	oTitle.className = 'tit';
	oContent.className = 'content';
	odel.className = 'delete';
	
	oTitle.innerHTML = oTit.value;
	oContent.innerHTML = oArea.value;
	odel.type = 'checkbox';
	
	aAnn.appendChild(oTitle);
	aAnn.appendChild(oContent);
	aAnn.appendChild(odel);
	oAgomess.children[0] ? oAgomess.insertBefore(aAnn,oAgomess.children[0]) : oAgomess.appendChild(aAnn);

	$.ajax({
			type:"post",
			url:"",
			async:true,
			data:{
				'historyList':[{
					"title":"oTitle".innerHTML,
					"content":"oContent".innerHTML
				}]
			},
			dataType:'json',
			success: function(data){
				if(data.success){
					$('#cue').html("发布成功" + data.msg);
				}else{
					$('#cue').html("出现错误" + data.msg);
				}
			},
			error:function(jqXHR){
				$("#cue").html("发生错误"+jqXHR);
			}
		});
}

$(document).ready(function(){
	$.ajax({
		type:"get",
		url:"",
		async:true,
		
		success:function(result){
			var html = '';
			var data = JSON.parse(result);
			$.each(data, function(commentIndex, comment){
								
	                     html += '<li><span  class="tit">' + comment['title'] + '</span><span class="content">' 
	                            + comment['content'] + '</span><input type="checkbox" class="delete" />'
	                            + '</li>';
                 });
            $('#agomess').html(html);			
		},
		error:function(){
			$('#cue').html('获取数据错误');
		}
			
	});
		
	
});



	var aLi = oAgomess.getElementsByTagName('li');
	var deleteJson = "[{'title':'','content':''}]";
	var deleteArray = JSON.parse('('+jsonstr+')');
	oDelete.onclick = function(){
		var aDel = oAgomess.getElementsByTagName('input');
		
		
		var count = 0;
		for(var i = 0; i < aDel.length;i++)
		{
			if(aDel[i].checked)
			{
				
				var arr = {
			         "title" : $('#agomess li:eq(i) span:eq(0)').html(),
			         "content" : $('#agomess li:eq(i) span:eq(1)').html()
			    }
				deleteArray.push(arr);
				agomess.removeChild(aDel[i].parentNode);
				i--;
			}
		}
		$.ajax({
			type:"post",
			url:"",
			async:true,
			dataType:'json',
			data:deleteArray,
			success:function(){
				$('#cue').html('删除成功');
			}
			error:function(jqXHR){
				$('#cue').html("上传错误" + jqXHR.status);
			}
		});
	}
	
		
//鼠标右键点击事件
//		aLi[j].onmousedown = function(eve){  
//	        var eve = eve || window.event; 
//	        if(eve.button == "2"){
//	        	var odel = aLi[this.index].document.getElementsByTagName('p')[0];
//	        	alert(odel);
//	        	//odel.style.display = 'block'; 
//	        }  
//	   }  		

//获取当前时间
function showTime(){
	var myTime = new Date();
	var iYear = myTime.getFullYear();
	var iMonth = myTime.getMonth()+1; 
	var iDate = myTime.getDate();
	var iWeek = myTime.getDay();
	if(iWeek === 0)iWeek = '星期日';
	if(iWeek === 1)iWeek = '星期一';
	if(iWeek === 2)iWeek = '星期二';
	if(iWeek === 3)iWeek = '星期三';
	if(iWeek === 4)iWeek = '星期四';
	if(iWeek === 5)iWeek = '星期五';
	if(iWeek === 6)iWeek = '星期六';
	var iHours = myTime.getHours();
	var iMinutes = myTime.getMinutes();
	var iSeconds = myTime.getSeconds();
	var str = '';
	str = addZ(iYear)+'.'+addZ(iMonth)+'.'+addZ(iDate)+'.'+addZ(iHours);
	return str;
//	for(var i = 0; i<aImg.length;i++){
//		aImg[i].src = 'img/' + str.charAt(i) +'.JPG';
//	}
}
function addZ(a){
	return a<10 ? a='0'+a : a=''+a;
}

